<?php
include "../mysql.php";

$username = $_REQUEST["username"]; 
$pwd = md5($_REQUEST["pwd"]); 
$email = $_REQUEST["email"]; 
$phone = $_REQUEST["phone"]; 
$nickname= $_REQUEST["nickname"]; 

if($_REQUEST["id"]){
  $id=$_REQUEST["id"];
  $sql="update `user` set username='".$username."',pwd='".$pwd."',email='".$email."',phone='".$phone."' ,nickname='".$nickname."' where id='$id'";
} else {
  $sql="insert `user`(`username`,`pwd`,`email`,`phone`,`nickname`) values('$username','$pwd','$email','$phone','$nickname');";
}


$result = mysql_query($sql);  
if (!$result) {
  printf("Error: %s\n", mysql_query($con));
  exit();
}

$jobj=new stdclass();//实例化stdclass，这是php内置的空类，可以用来传递数据，由于json_encode后的数据是以对象数组的形式存放的，
$jobj->success=true;

echo json_encode($jobj);//打印编码后的json字符串




mysql_close($con);//关闭数据库连接
?>